import { BrowserWindow } from 'electron';
import path from 'path'



class plugInWindow {
    constructor(param) {
        const plugInIconPath = path.join(path.resolve('./'), './plugIn/' + param.path + param.icon);
        const plugInRootPath = path.join(path.resolve('./'), './plugIn/' + param.path + '/' + param.root);

        let win = new BrowserWindow({
            height: 800,
            width: 1280,
            minWidth: 1280,
            minHeight: 800,
            useContentSize: false,
            frame: false,
            show: false,
            icon: plugInIconPath,
            webPreferences: {
                nodeIntegration: true,
                webSecurity: false
            }
        });
        win.once('ready-to-show', () => {
            win.show();
        });
        win.loadURL(plugInRootPath);
        win.webContents.on('get-window-options', function () {
            win.webContents.send('send-window-options', JSON.stringify(param));
        });
        this.win = win;
    }
    show() {
        this.win.show();
    }
    focus() {
        this.win.focus();
    }
    onClose(event) {
        this.closeEvent = event;
    }
};



export default plugInWindow;